Skip to content

Complexity Notation

links: AC2 TOC - Number-Theoretic Algorithms and Hardness Assumptions - Index


Different algorithmic complexities

From fast to slow

  • O(1) - Constant time
  • O(logn) - Logarithmic time
  • O(n) - Square root time
  • O(n) - Linear time
  • O(nlogn) - Linear logarithmic time
  • O(n2) - Quadratic time
  • O(n3) - Cubic time
  • O(nk) - Polynomial time
  • O(2n) - Exponential time
  • O(n!) - Factorial time
  • O(nn) - "Crazy" exponential time

From the slides: Complexity_Notation.png

Notation

For some function f(n)

  • Big O notation: O(f(n)) - Upper bound. Worst case scenario. (Less or equal)
  • Little o notation: o(f(n)) - Upper bound. Worst case scenario. (Strictly less)
  • Big Omega notation: Ω(f(n)) - Lower bound. Best case scenario. (Greater or equal)
  • Little omega notation: ω(f(n)) - Lower bound. Best case scenario. (Strictly greater)
  • Big Theta notation: Θ(f(n)) - Equal. Average case scenario.

Master Theorem

To analyse recursive function we need the Master Theorem.

Decrease (R1-2) the problem size by k:

T(n)={cif n=dq×T(nk)+f(n)if n>d

Divide (D1-4) the problem size by r:

T(n)={cif n=dq×T(n/r)+f(n)if n>d

Master_Theorem.png


links: AC2 TOC - Number-Theoretic Algorithms and Hardness Assumptions - Index